home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / comm / term / term_source.lha / Extras / Source / term-source.lha / Start.c < prev    next >
C/C++ Source or Header  |  1996-10-20  |  4KB  |  181 lines

  1. /*
  2. **    Start.c
  3. **
  4. **    The program entry point
  5. **
  6. **    Copyright © 1990-1996 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #ifndef _COMPILER_H
  13. #include "Compiler.h"
  14. #endif    /* _COMPILER_H */
  15.  
  16. #ifndef INTUITION_INTUITIONBASE_H
  17. #include <intuition/intuitionbase.h>
  18. #endif    /* INTUITION_INTUITIONBASE_H */
  19.  
  20. #ifndef WORKBENCH_WORKBENCH_H
  21. #include <workbench/workbench.h>
  22. #endif    /* WORKBENCH_WORKBENCH_H */
  23.  
  24. #ifndef EXEC_EXECBASE_H
  25. #include <exec/execbase.h>
  26. #endif    /* EXEC_EXECBASE_H */
  27.  
  28. #ifndef EXEC_MEMORY_H
  29. #include <exec/memory.h>
  30. #endif    /* EXEC_MEMORY_H */
  31.  
  32. #ifndef DOS_DOSEXTENS_H
  33. #include <dos/dosextens.h>
  34. #endif    /* DOS_DOSEXTENS_H */
  35.  
  36. #ifndef DOS_EXALL_H
  37. #include <dos/exall.h>
  38. #endif    /* DOS_EXALL_H */
  39.  
  40. #ifndef CLIB_INTUITION_PROTOS_H
  41. #include <clib/intuition_protos.h>
  42. #endif    /* CLIB_INTUITION_PROTOS_H */
  43.  
  44. #ifndef CLIB_EXEC_PROTOS_H
  45. #include <clib/exec_protos.h>
  46. #endif    /* CLIB_EXEC_PROTOS_H */
  47.  
  48. #ifndef CLIB_DOS_PROTOS_H
  49. #include <clib/dos_protos.h>
  50. #endif    /* CLIB_DOS_PROTOS_H */
  51.  
  52. #ifdef __GNUC__
  53. #include <inline/intuition.h>
  54. #include <inline/exec.h>
  55. #include <inline/dos.h>
  56. #endif    /* __GNUC__ */
  57.  
  58. #ifndef NO_PRAGMAS
  59. #include <pragmas/intuition_pragmas.h>
  60. #include <pragmas/exec_pragmas.h>
  61. #include <pragmas/dos_pragmas.h>
  62. #endif    /* NO_PRAGMAS */
  63.  
  64. #include <string.h>
  65.  
  66.     /* Standard topaz.font/8. */
  67.  
  68. extern struct TextAttr         DefaultFont;
  69.  
  70.     /* Library base pointers. */
  71.  
  72. extern struct ExecBase        *SysBase;
  73. extern struct DosLibrary    *DOSBase;
  74. extern struct IntuitionBase    *IntuitionBase;
  75.  
  76.     /* The appropriate machine type check. */
  77.  
  78. #if defined(CPU_ANY)
  79. #define MACHINE_OKAY (1)
  80. #else
  81. #define MACHINE_OKAY (SysBase->AttnFlags & AFF_68020)
  82. #endif
  83.  
  84.     /* Start():
  85.      *
  86.      *    Program entry point, checks for the right CPU type and
  87.      *    runs the main program if possible.
  88.      */
  89.  
  90. LONG SAVE_DS STACKARGS
  91. Start(VOID)
  92. {
  93.     extern LONG Main(VOID);
  94.  
  95.     LONG Result = RETURN_FAIL;
  96.  
  97.         /* Get SysBase. */
  98.  
  99.     SysBase = *(struct ExecBase **)4;
  100.  
  101.         /* Is the minimum required processor type and Kickstart 2.04 (or higher)
  102.          * available?
  103.          */
  104.  
  105.     if(MACHINE_OKAY && (SysBase->LibNode.lib_Version > 37 || (SysBase->LibNode.lib_Version == 37 && SysBase->SoftVer >= 175)))
  106.         Result = Main();
  107.     else
  108.     {
  109.         struct Process *ThisProcess = (struct Process *)FindTask(NULL);
  110.  
  111.             /* Is a Shell window available? */
  112.  
  113.         if(ThisProcess->pr_CLI)
  114.         {
  115.                 /* Show the message. */
  116.  
  117.             if(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",0))
  118.             {
  119.                 STRPTR String;
  120.  
  121.                 if(MACHINE_OKAY)
  122.                     String = "Kickstart 2.04 or higher required.\a\n";
  123.                 else
  124.                     String = "MC68020 or higher required.\a\n";
  125.  
  126.                 Write(Output(),String,strlen(String));
  127.  
  128.                 CloseLibrary((struct Library *)DOSBase);
  129.             }
  130.         }
  131.         else
  132.         {
  133.             struct WBStartup *WBenchMsg;
  134.  
  135.                 /* Wait for startup message. */
  136.  
  137.             WaitPort(&ThisProcess->pr_MsgPort);
  138.  
  139.                 /* Get the message. */
  140.  
  141.             WBenchMsg = (struct WBStartup *)GetMsg(&ThisProcess->pr_MsgPort);
  142.  
  143.                 /* Show the message. */
  144.  
  145.             if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))
  146.             {
  147.                 STATIC struct IntuiText SorryText = {0,1,JAM1,6,3,&DefaultFont,(STRPTR)"Sorry",NULL};
  148.                 struct IntuiText *Body;
  149.                 LONG Width;
  150.  
  151.                 if(MACHINE_OKAY)
  152.                 {
  153.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(STRPTR)"Kickstart 2.04 or higher required.",NULL};
  154.  
  155.                     Body    = &BodyText;
  156.                     Width    = 309;
  157.                 }
  158.                 else
  159.                 {
  160.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(STRPTR)"MC68020 or higher required.",NULL};
  161.  
  162.                     Body    = &BodyText;
  163.                     Width    = 253;
  164.                 }
  165.  
  166.                 AutoRequest(NULL,Body,NULL,&SorryText,NULL,NULL,Width,46);
  167.  
  168.                 CloseLibrary((struct Library *)IntuitionBase);
  169.             }
  170.  
  171.                 /* Return the startup message and exit. */
  172.  
  173.             Forbid();
  174.  
  175.             ReplyMsg((struct Message *)WBenchMsg);
  176.         }
  177.     }
  178.  
  179.     return(Result);
  180. }
  181.